 <!DOCTYPE html>
 <html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
 </head>
 <body>
  <script>

    var str = 'Hello world'

    // 查找字符串 找到了会返回字符串的索引 找不到会返回-1
    console.log(str.indexOf("wor"));

    // 是否包含字符串
    console.log(str.includes("wo"))
    // 是否以xx开头
    console.log(str.startsWith("he"))
    // 是否以xx结尾
    console.log(str.endsWith("ld"))

    // 替换字符串
    console.log(str.replace("He","hh"))
  </script>
 </body>
 </html>